<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
    request.setCharacterEncoding("UTF-8");
%>
<!doctype html>
<html>
<head>
    <meta charset="utf-8" />
    <title>KindEditor JSP</title>
    <script src="${pageContext.request.contextPath}/resource/static/layui-mini-2-onepage/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
    <script charset="utf-8" src="${pageContext.request.contextPath}/resource/static/kindeditor/kindeditor-all-min.js"></script>
    <script charset="utf-8" src="${pageContext.request.contextPath}/resource/static/kindeditor/lang/zh-CN.js"></script>

    <link rel="stylesheet" href="${pageContext.request.contextPath}/resource/static/kindeditor/themes/default/default.css" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resource/static/kindeditor/plugins/code/prettify.css" />
    <script charset="utf-8" src="${pageContext.request.contextPath}/resource/static/kindeditor/plugins/code/prettify.js"></script>
    <script>

        KindEditor.ready(function(K) {

            var options = {
                cssPath : '/resource/static/kindeditor/plugins/code/prettify.css',
                uploadJson : '/resource/static/kindeditor/jsp/upload_json.jsp',
                fileManagerJson : '/resource/static/kindeditor/jsp/file_manager_json.jsp',
                filterMode : false ,        // 关闭过滤模式，保留所有标签
                allowFileManager : true,
            };

            window.editor = K.create('#editor_id',options);

        });

        window.getEditorContent = function getEditorContent(){
            // 取得HTML内容
            // html = editor.html();

            // 同步数据后可以直接取得textarea的value
            editor.sync();
            html = document.getElementById('editor_id').value; // 原生API
            html = $('#editor_id').val(); // jQuery

            // 设置HTML内容
            return editor.html();
        }
    </script>
</head>
<body>
    <textarea id="editor_id" name="content" cols="100" rows="8" style="width:100%;height:700px;visibility:hidden;"></textarea>
</body>
</html>
